package com.runda.entity;

import java.util.Collection;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import com.bbjob.model.User;

public class JwtUser implements UserDetails{
	private static final long serialVersionUID = 2574737313153460277L;
	private Integer id;
    private String username;
    private String password;
    private Integer oriCode;
    public Integer getOriCode() {
		return oriCode;
	}

	public void setOriCode(Integer oriCode) {
		this.oriCode = oriCode;
	}
	private Collection<? extends GrantedAuthority> authorities;
    public JwtUser(User user,Collection<? extends GrantedAuthority> authorities) {
        id = user.getId();
        username = user.getUsername();
        password = user.getPassword();
        this.oriCode=user.getOrganId();
        this.authorities=authorities;
    }

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return authorities;
	}
	public Integer getId() {
		return this.id;
	}

	@Override
	public String getPassword() {
	
		return this.password;
	}

	@Override
	public String getUsername() {
	
		return this.username;
	}

	@Override
	public boolean isAccountNonExpired() {	
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		
		return true;
	}

	@Override
	public boolean isEnabled() {
		return true;
	}
	 @Override
	    public String toString() {
	        return "JwtUser{" +
	                "id=" + id +
	                ", username='" + username + '\'' +
	                ", password='" + password + '\'' +
	                ", authorities=" + authorities +
	                '}';
	    }

	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @param username the username to set
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @param authorities the authorities to set
	 */
	public void setAuthorities(Collection<? extends GrantedAuthority> authorities) {
		this.authorities = authorities;
	}
	
}
